<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>系统功能</title>
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/themes/icon.css">
	<script type="text/javascript" src="${ctx}/script/jquery.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/script/lhgdialog/lhgdialog.min.js?s=facebook"></script>
	<script type="text/javascript" src="${ctx}/script/CheckText.js"></script>
	<script type="text/javascript">
		var dg = frameElement.lhgDG;
		dg.addBtn( 'ok', '确定', function(){
			if (!checkFormItem(document.getElementById("jdmc"),"C",50,0,1,"功能名称")) return false;
			if (!checkFormItem(document.getElementById("gndz"),"C",50,0,2,"功能地址")) return false;
			submitForm();
		});
		
		function submitForm() {
			var pId = $("#id").val();
			var pFid = $("#fid").val();
			var pLbmc= $("#jdmc").val();
			var pGndz = $("#gndz").val();
			var pJdlb = $("#jdlb").val().length > 0 ? $("#jdlb").val() : 2;
			var pGnsm = $("#gnsm").val();
			var params = {
				"gg_xtgn.id" : pId,
				"gg_xtgn.fid" : pFid,
				"gg_xtgn.jdmc" : pLbmc,
				"gg_xtgn.gndz" : pGndz,
				"gg_xtgn.jdlb" : pJdlb,
				"gg_xtgn.gnsm" : pGnsm,
			};
			var actionUrl = "saveGG_XTGN.action";
			$.ajax( {
				url : actionUrl,
				data : params,
				dataType : "json",
				cache : false,
				error : function(textStatus, errorThrown) {alert("系统ajax交互错误: " + textStatus);},
				success : function(data, textStatus) {
					if (data.ajaxResult == "success") {
						var dataRow = {
							ID: data.gg_xtgn.id,
							FID: data.gg_xtgn.fid,
							JDMC: data.gg_xtgn.jdmc,
							GNDZ: data.gg_xtgn.gndz,
							JDLB: data.gg_xtgn.jdlb,
							GNSM: data.gg_xtgn.gnsm
						};
						if(pId == "") {
							dg.curWin.$("#gridTable").addRowData(data.gg_xtgn.id, dataRow, "last");
							var newNode = [{id:data.gg_xtgn.id, name:data.gg_xtgn.jdmc, fid:data.gg_xtgn.fid}];
							dg.curWin.addTreeNode(data.gg_xtgn.fid,newNode);
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
						} else {
							var rowId = dg.curWin.$("#gridTable").getGridParam('selrow');
							//dg.curWin.$("#gridTable").setRowData(rowId, dataRow, {color:"#FF0000"});
							dg.curWin.$("#gridTable").setRowData(rowId, dataRow);
							dg.curWin.updateTreeNode(data.gg_xtgn.id,data.gg_xtgn.jdmc);
							new dg.curWin.$.dialog({id:'2',title:'信息提示页面',page:'${ctx}/success.jsp',rang:true,iconTitle:false}).ShowDialog();
							dg.cancel();
						}
					} else {
						dg.curWin.alert("修改操作失败!");
					}
				}
			});
		}
		
		$(document).ready(function(){
			initSelectOption();
		});
		
		function initSelectOption() {
			var optionValue = $("#jdlb").val();
			if(optionValue.length > 0) {
				$("select[@name='gg_xtgn.jdlb'] option").each(function(){
					if($(this).val() == optionValue) {
						$(this).attr("selected",true);
					} 
				});
			}
		}
		
		function setValue(value) {
			$("#jdlb").val(value);
		}
	</script>
</head>
<body>
<form id="ff" method="post">
<input type="hidden" id ="id" name="gg_czlb.id" value="${gg_xtgn.id}">
<input type="hidden" id ="fid" name="gg_czlb.fid" value="${gg_xtgn.fid}">
<input type="hidden" id ="jdlb" name="gg_xtgn.jdlb" value="${gg_xtgn.jdlb}">
<table id="tt" title="系统功能信息" iconCls="icon-title">
	<tbody>
	<tr>
		<td>功能名称：</td>
		<td><input id="jdmc"  name="gg_xtgn.jdmc" style="width:200px;" value="${gg_xtgn.jdmc}"></td>
	</tr>
	<tr>
		<td>功能地址：</td>
		<td><input id="gndz" name="gg_xtgn.gndz" style="width:200px;" value="${gg_xtgn.gndz}"></td>
	</tr>
	<tr>
		<td>功能类别：</td>
		<td>
			<select name="gg_xtgn.jdlb" style="width:206px;" onchange="setValue(this.value);">
				<option value="2">子功能</option>
				<option value="1">子模块</option>
				<option value="0">子系统</option>
			</select>
		</td>
	</tr>
	<tr>
		<td>功能说明：</td>
		<td><textarea id="gnsm" name="gg_xtgn.gnsm" rows="3" cols="30">${gg_xtgn.gnsm}</textarea></td>
	</tr>
	</tbody>
</table>
</form>
</body>
</html>